/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Random;
import java.util.Scanner;

/**
 * <p>Project: javase202202 - While4
 * <p>Powered by Lisi On 2022-06-02 09:52:45
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class While4 {
    public static void main(String[] args) {
        Random rand = new Random();
        Scanner sc = new Scanner(System.in);
        int[] lev = {10, 50, 100, 200, 500, 1000, 2000, 10000};
        int max = lev[rand.nextInt(lev.length)];
        //出题1-100 随机号数
        int num = rand.nextInt(max) + 1;
        String msg = "";
        int index = 0;
        while (true) {
            ++index;
            System.out.print("请输入数字(1-" + max + "):");
            int t = sc.nextInt();
            if (t <= 0) {
                msg = String.format("放弃游戏，程序退出。");
                break;
            }
            if (t > num) {
                //太大了
                msg = String.format("%d、太大了。", index);
            } else if (t < num) {
                //太小了
                msg = String.format("%d、太小了。", index);
            } else {
                //恭喜你猜对了.
                msg = String.format("%d、恭喜猜对了，你的游戏（%d分）。", index, 110 - index * 10);
                break;
            }
            System.out.println(msg);
        }
        System.out.println(msg);
    }
}
